const request = require('request');
const async = require('async');


function visiteSite(url, cb) {
	request({
		url: url,
		headers: {
			'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
			'Accept-Language': 'zh-CN,zh;q=0.8,zh-HK;q=0.6',
			'Cache-Control': 'no-cache',
			'Connection': 'keep-alive',
			'Host': 'www.weather.com.cn',
			'Cookie': 'Cookie:vjuids=b0c1a8c07.158e6c187c2.0.af5fb7081bf17; f_city=%E6%AD%A6%E6%B1%89%7C101200101%7C; Hm_lvt_080dabacb001ad3dc8b9b9049b36d43b=1481340193; Hm_lpvt_080dabacb001ad3dc8b9b9049b36d43b=1481348000; vjlast=1481340193.1481340193.30',
			'Pragma': 'no-cache',
			'Referer': 'http://www.weather.com.cn/weather/101200101.shtml',
			'Upgrade-Insecure-Requests': 1,
			'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.99 Safari/537.36',
		}
	}, function(err, response, body) {
		if (err) return cb(err);
		if (response.statusCode != 200) {
			return cb(new Error(`response code ${response.statusCode}`));
		}
		cb(null, response.body);
	})
}

visiteSite(`http://d1.weather.com.cn/sk_2d/101200101.html?_=${new Date().getTime()}`,(err,result)=>{
	if (err) {
		console.log(err)
		return
	}
	console.log(result)
})
/**
 * 做了反爬虫机制，不想研究。。
 */